package com.example.a79273.shandianban.model;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * 现货
 */
public class XianHuoBean {

    /**
     * error_code : 0
     * error_msg : 获取现货成功！
     * total : 9
     * data : {"lists":[{"fatherid":"","fathername":"fantastic baby","Hsrc":"","Vsrc":"/Upload/Product/237000320140/372e706c18.jpg","Asrc":"","pid":"237000320031","href":"api/Mall/ProductsDetails/237000320140","name":"黄伟仪"},{"fatherid":"","fathername":"fantastic baby","Hsrc":"","Vsrc":"/Upload/Product/237000320256/372e8eeea9.jpg","Asrc":"","pid":"237000320031","href":"api/Mall/ProductsDetails/237000320256","name":"黄伟仪"},{"fatherid":"","fathername":"fantastic baby","Hsrc":"","Vsrc":"/Upload/Product/237000320387/372e7fac6a.jpg","Asrc":"","pid":"237000320031","href":"api/Mall/ProductsDetails/237000320387","name":"黄伟仪"},{"fatherid":"","fathername":"fantastic baby","Hsrc":"","Vsrc":"/Upload/Product/240000760516/37e1383d68.jpg","Asrc":"","pid":"237000320031","href":"api/Mall/ProductsDetails/240000760516","name":"黄伟仪"},{"fatherid":"","fathername":"fantastic baby","Hsrc":"","Vsrc":"/Upload/Product/240000760697/37e1383ed6.jpg","Asrc":"","pid":"237000320031","href":"api/Mall/ProductsDetails/240000760697","name":"黄伟仪"},{"fatherid":"","fathername":"fantastic baby","Hsrc":"","Vsrc":"/Upload/Product/240000760748/37e1477dfc.jpg","Asrc":"","pid":"237000320031","href":"api/Mall/ProductsDetails/240000760748","name":"黄伟仪"},{"fatherid":"","fathername":"学话","Hsrc":"","Vsrc":"/Upload/Product/237000320488/372e7fad92.jpg","Asrc":"","pid":"237000320031","href":"api/Mall/ProductsDetails/237000320488","name":"黄伟仪"},{"fatherid":"","fathername":"学话","Hsrc":"","Vsrc":"/Upload/Product/237000320519/372e8eee64.jpg","Asrc":"","pid":"237000320031","href":"api/Mall/ProductsDetails/237000320519","name":"黄伟仪"},{"fatherid":"","fathername":"学话","Hsrc":"","Vsrc":"/Upload/Product/237000320635/372e8eed77.jpg","Asrc":"","pid":"237000320031","href":"api/Mall/ProductsDetails/237000320635","name":"黄伟仪"}]}
     */

    private int error_code;
    private String error_msg;
    private int total;
    private DataBean data;

    public static XianHuoBean objectFromData(String str) {

        return new Gson().fromJson(str, XianHuoBean.class);
    }

    public static XianHuoBean objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), XianHuoBean.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<XianHuoBean> arrayXianHuoBeanFromData(String str) {

        Type listType = new TypeToken<ArrayList<XianHuoBean>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<XianHuoBean> arrayXianHuoBeanFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<XianHuoBean>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public int getError_code() {
        return error_code;
    }

    public void setError_code(int error_code) {
        this.error_code = error_code;
    }

    public String getError_msg() {
        return error_msg;
    }

    public void setError_msg(String error_msg) {
        this.error_msg = error_msg;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * fatherid :
         * fathername : fantastic baby
         * Hsrc :
         * Vsrc : /Upload/Product/237000320140/372e706c18.jpg
         * Asrc :
         * pid : 237000320031
         * href : api/Mall/ProductsDetails/237000320140
         * name : 黄伟仪
         */

        private List<ListsBean> lists;

        public static DataBean objectFromData(String str) {

            return new Gson().fromJson(str, DataBean.class);
        }

        public static DataBean objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), DataBean.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<DataBean> arrayDataBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<DataBean>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<DataBean> arrayDataBeanFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<DataBean>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public List<ListsBean> getLists() {
            return lists;
        }

        public void setLists(List<ListsBean> lists) {
            this.lists = lists;
        }

        public static class ListsBean {
            private String fatherid;
            private String fathername;
            private String Hsrc;
            private String Vsrc;
            private String Asrc;
            private String pid;
            private String href;
            private String name;

            public static ListsBean objectFromData(String str) {

                return new Gson().fromJson(str, ListsBean.class);
            }

            public static ListsBean objectFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);

                    return new Gson().fromJson(jsonObject.getString(str), ListsBean.class);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return null;
            }

            public static List<ListsBean> arrayListsBeanFromData(String str) {

                Type listType = new TypeToken<ArrayList<ListsBean>>() {
                }.getType();

                return new Gson().fromJson(str, listType);
            }

            public static List<ListsBean> arrayListsBeanFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);
                    Type listType = new TypeToken<ArrayList<ListsBean>>() {
                    }.getType();

                    return new Gson().fromJson(jsonObject.getString(str), listType);

                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return new ArrayList();


            }

            public String getFatherid() {
                return fatherid;
            }

            public void setFatherid(String fatherid) {
                this.fatherid = fatherid;
            }

            public String getFathername() {
                return fathername;
            }

            public void setFathername(String fathername) {
                this.fathername = fathername;
            }

            public String getHsrc() {
                return Hsrc;
            }

            public void setHsrc(String Hsrc) {
                this.Hsrc = Hsrc;
            }

            public String getVsrc() {
                return Vsrc;
            }

            public void setVsrc(String Vsrc) {
                this.Vsrc = Vsrc;
            }

            public String getAsrc() {
                return Asrc;
            }

            public void setAsrc(String Asrc) {
                this.Asrc = Asrc;
            }

            public String getPid() {
                return pid;
            }

            public void setPid(String pid) {
                this.pid = pid;
            }

            public String getHref() {
                return href;
            }

            public void setHref(String href) {
                this.href = href;
            }

            public String getName() {
                return name;
            }

            public void setName(String name) {
                this.name = name;
            }
        }
    }
}
